import java.util.*;

public class Main {
    public int strStr(String haystack, String needle) {
        if(haystack.length() < needle.length()) {
            return -1;
        }
        for(int i = 0;i < haystack.length();i++) {
            int j = 0;
            while(i+j < haystack.length() && j<needle.length() && haystack.charAt(i+j)==needle.charAt(j)) {
                j++;
            }
            if(j == needle.length()) {
                return i;
            }
        }
        return -1;
    }
    public static int count;
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        while (in.hasNextInt()) { // 注意 while 处理多个 case
            count = 0;
            int a = in.nextInt();
            int array[] = new int[a];
            for(int i = 0;i < a;i++) {
                array[i] = in.nextInt();
            }
            Arrays.sort(array);
            lucky(array);
            System.out.println(count);
        }
    }
    public static void func(int[] array,int[] used,int index,int sum,int amass) {
        if(array.length == index) {
            if(sum > amass) {
                count++;
            }
            return;
        }
        for(int i = index;i < array.length;i++) {
            if(i>0 && array[i] == array[i-1] && used[i-1] == 0) {
                continue;
            }
            used[i] = 1;
            sum += array[i];
            amass *= array[i];
            func(array,used,i+1,sum,amass);
            used[i] = 0;
            sum -= array[i];
            amass /= array[i];

        }

    }
    public static void lucky(int[] array) {
        int[] used = new int[array.length];
        func(array,used,0,0,1);
    }
}
